package com.cuit.house.mapper;


import com.cuit.house.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;

public interface UserMapper extends JpaRepository<User, Integer> {
   //查询用户
   User findByPasswordAndPhonenumber(@Param("password") String Password,@Param("Phonenumber") String Phonenumber);

   //更新信息
    @Modifying
    @Query(value="update User u set u.password=:password where u.phonenumber=:phonenumber")
    int update(@Param("password") String Password, @Param("phonenumber") String Phonenumber);

    @Modifying
    @Query(value="update User u set u.username=:username,u.birthday=:birthday,u.address=:address,u.avatar=:avatar where u.phonenumber=:phonenumber")
    int updateAll(@Param("username") String username, @Param("birthday") Date birthday, @Param("address") String address, @Param("avatar") String avatar, @Param("phonenumber") String phonenumber);
}
